<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/19
  Time: 12:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<% String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<script src="<%=path%>/static/js/jquery-3.5.1.min.js"></script>
<style>
    table tr img{
        width: 50px;
        height: 50px;
    }
    table tr{
        text-align: center;
    }
</style>
<script>
    $(function () {
        $(".allChoose").click(function () {
            $(":checkbox[id='choose']").prop("checked",$(this).prop("checked"));
        });
    });
    $(function () {
        $("#batchDel").click(function () {
            var idArr = new Array();
            $(":checked[id='choose']").each(function () {
                idArr.push($(this).val());
            });
            $.get("<%=path%>/manage/comment/batchDelReply",{ids:idArr.toString()},function () {
                $(":checked[id='choose']").parent().parent().remove();
            });
        });
    });

    //删除
    $(function () {
        $(".link-del").click(function () {
            var id = $(this).attr("id");
            alert(id);
            $.get("<%=path%>/manage/comment/linkDel",{id:id},function () {
                $(this).parent().parent().remove();
            }.bind(this));
        });
    });
</script>
<jsp:include page="/manage/inc/header"/>
<jsp:include page="/manage/inc/menu"/>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="#">评论管理</a><span class="crumb-step">&gt;</span><span>查看回复</span></div>
        </div>
        <div class="result-wrap">
        <div class="result-title">
            <div class="result-list">
                <a id="batchDel" href="javascript:void(0)"><i class="icon-font"></i>批量删除</a>
            </div>
        </div>
        <div class="result-content">
            <table class="result-tab" width="100%">
                <tr>
                    <th class="tc" width="5%"><input class="allChoose" type="checkbox"></th>
                    <th>用户名</th>
                    <th>性别</th>
                    <th>头像</th>
                    <th>评论内容</th>
                    <th>评论时间</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${requestScope.comments}" var="comment">
                    <tr>
                        <td class="tc"><input name="id[]" id="choose" value="${comment.id}" type="checkbox"></td>
                        <td>${comment.userinfo.username}</td>
                        <td>
                            <c:if test="${comment.userinfo.sex eq null}">
                                保密
                            </c:if>
                            <c:if test="${comment.userinfo.sex ne null}">
                                ${comment.userinfo.sex}
                            </c:if>
                        </td>
                        <td>
                            <c:if test="${comment.userinfo.headImage eq null}">
                                <img src="<%=path%>/static/web/images/default_headpic.png">
                            </c:if>
                            <c:if test="${comment.userinfo.headImage ne null}">
                                <img src="<%=path%>/static/uploadImg/${comment.userinfo.headImage}">
                            </c:if>
                        </td>
                        <td>${fn:substring(comment.content,0 ,10 )}${fn:length(comment.content)gt 10?'...':''}</td>
                        <td><fmt:formatDate value="${comment.inputTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                        <td>
                            <a class="link-del" href="#" id="${comment.id}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
        </div>
        <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">

    </div>
    <!--/main-->
</div>
<jsp:include page="/manage/inc/footer"/>
